const Joi = require('joi')
// 引入 models
let index = {
    method: 'GET',
    path: '/',
    config: {
        tags: ['api', 'tests'],
        description: '测试hello-hapi'
    },
    handler: function (request, reply) {
        reply('hello,world');
    }
};
let hello = {
    method: ['GET', 'POST'],
    path: '/hello/{user?}',
    config: {
        validate: {
            params: {
                user: Joi.string().required()
            }
        }
    },
    handler: function (request, reply) {
        reply('Hello ' + encodeURIComponent(request.params.user) + '!');
    }
};

module.exports = [index, hello];
